package de.mhu.mandalaui.list;

import de.mhu.mandalaui.Component;
import de.mhu.mandalaui.Response;
import de.mhu.mandalaui.actions.ClickAction;
import de.mhu.mandalaui.attributes.ArrayAttribute;

public class SelectableList extends Component {

	private ListItem item;
	private ArrayAttribute data = null;
	private ClickAction selectAction = null;

	@Override
	protected void doInitialize() {
		data = new ArrayAttribute();
		data.setOwner(this);
	}

	@Override
	protected void doDestroy() {
		data = null;
	}

	@Override
	public void render(Response response) {
		data.startRender(response);
		item.checkSelectableAction();
		
		response.startTag("div", "list-group" , this, "data-bind","foreach: " + data.getBindCall());
		
		response.startTag("a", "list-group-item", item, "href","#");
		response.containerEnter(item);
		item.render(response);
		response.containerLeave();
		response.endTag("a");
		
		response.endTag("div");

	}

	public ListItem getItem() {
		return item;
	}

	public void setItem(ListItem item) {
		this.item = item;
		item.componentAttach(this);
	}

	public ArrayAttribute getDataAttribute() {
		return data;
	}

	public void setDataAttribute(ArrayAttribute data) {
		this.data = data;
	}

	public ClickAction getSelectAction() {
		return selectAction;
	}

	public void setSelectAction(ClickAction selectAction) {
		this.selectAction = selectAction;
	}

	
}
